<%@ page contentType="text/html; charset=utf-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
 
<f:message var="headline" key="humans.humans"/>
<s:layout-render name="/content.jsp" nadpis="${headline}">
    <s:layout-component name="telo">
        <s:useActionBean beanclass="cz.muni.fi.hauntedhousesweb.web.HumansActionBean" var="actionBean"/>
        <s:useActionBean beanclass="cz.muni.fi.hauntedhousesweb.web.HousesActionBean" var="housesBean"/>
        
        <table class="zakladni">
            <tr>
                <th><f:message key="humans.id"/></th>
                <th><f:message key="humans.name"/></th>
                <th><f:message key="humans.gender"/></th>
                <th><f:message key="humans.scareMeter"/></th>
                <th><f:message key="humans.resistance"/></th>
                <th><f:message key="humans.worstFear"/></th>
                <th><f:message key="humans.house"/></th>
                
            </tr>
            <c:forEach items="${actionBean.humans}" var="human">
                <tr>
                    <td>${human.id}</td>
                    <td><c:out value="${human.name}"/></td>
                    <td><f:message key="Gender.${human.gender}"/></td>
                    <td><c:out value="${human.scareMeter}"/></td>
                    <td><c:out value="${human.resistance}"/></td>
                    <td><f:message key="Fear.${human.worstFear}"/></td>
                    <td><c:out value="${human.house.name}"/></td>
                    <c:if test="${pageContext.request.isUserInRole('ROLE_ADMIN')}" >
                    <td><s:link beanclass="cz.muni.fi.hauntedhousesweb.web.HumansActionBean" event="delete"><s:param name="human.id" value="${human.id}"/><f:message key="humans.delete"/></s:link> </td>
                    <td><s:link beanclass="cz.muni.fi.hauntedhousesweb.web.HumansActionBean" event="edit"><s:param name="human.id" value="${human.id}"/><f:message key="humans.edit"/></s:link> </td>
                    </c:if>
                </tr>
            </c:forEach>
        </table>
        
        <c:if test="${pageContext.request.isUserInRole('ROLE_ADMIN')}" >
        <s:form beanclass="cz.muni.fi.hauntedhousesweb.web.HumansActionBean">
            <fieldset><legend><f:message key="humans.addnew"/></legend>
                <%@include file="formHuman.jsp"%>
            <s:submit name="add" class="button"><f:message key="humans.add"/></s:submit>
            </fieldset>
        </s:form>
        </c:if>
    </s:layout-component>
</s:layout-render>
